/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Operations;

/**
 *
 * @author littlechild
 */
public class CommonFunc {
    public static int getBlue(int rgb) {
        return rgb & 255;
    }
    public static int getRed(int rgb) {
        return (rgb>>>16) & 255;
    }
    public static int getGreen(int rgb) {
        return (rgb>>>8) & 255;
    }
    public static int getGray(int rgb) {
        return round(0.11*(rgb & 255) + 0.3*((rgb>>>16) & 255) +0.59*((rgb>>>8) & 255));
    }
    public static int round(double d) {
        return (int)(d+0.5);
    }
    public static int getRGB(int r, int g,int b) {
        assert r<=255 & b<=255 & g<=255;
        return (b)|(g<<8)|(r<<16);
    }
}
